import Vue from 'vue'
import VueRouter from 'vue-router'
import LayOut from '../mianjing/LayOut.vue'
import Login from '../mianjing/Login.vue'
import Register from '../mianjing/Register.vue'
import Home from '../mianjing/sub/Home.vue'
import My from '../mianjing/sub/My.vue'
import Collect from '../mianjing/sub/Collect.vue'
import Like from '../mianjing/sub/Like.vue'
import Detail from '../mianjing/Detail.vue'

Vue.use(VueRouter)
    //路由规则
const routes = [{
        // path: '/', //路径即路由值
        path: '/', //路径即路由值
        redirect: '/home',
        name: 'LayOut',
        component: LayOut, //组件匹配
        children: [{
            path: 'home',
            name: 'home',
            component: Home,
            meta: {
                keepAlive: true

            }
        }, {
            path: '/collect',
            name: 'collect',
            component: Collect
        }, {
            path: '/my',
            name: 'my',
            component: My
        }, {
            // path: '/like',
            path: 'like',
            name: 'like',
            component: Like
        }, ]
    },
    {
        path: '/login', //自定义名字
        name: 'Login', //自定义名字
        component: Login //注册的组件名和导入的组件名要一致
    },
    {
        path: '/register', //自定义名字
        name: 'Register', //自定义名字
        component: Register //注册的组件名和导入的组件名要一致
    },
    {
        path: '/detail/:id', //自定义名字
        name: 'detail', //自定义名字
        component: Detail //注册的组件名和导入的组件名要一致
    },

]

const router = new VueRouter({
    routes,
    // mode: 'hash' d当配置选择【? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)】y时则需要转hash模式，从而能解析#
    // linkExactActiveClass: 'ee',
    // linkActiveClass: 'aa'
})

export default router